<HTML>
<HEAD>
<TITLE>New Page</TITLE>
</HEAD>
<BODY>
<script language="javascript">
function initvlc(){
	document.getElementById("MyActiveX1").InitVLCInstance();
	document.getElementById("MyActiveX1").SetStunServer("202.102.108.42","3478");
}

function uninitvlc(){
	document.getElementById("MyActiveX1").UnInitVLCInstance();
}

function InitMediaPlayerWithMediaPath(){
	//InitMediaPlayerWithMediaPath2()  //tcpģʽ
	
	//var url = 'rtsp://221.226.150.238:5504/realplay?devid=81152397415&channelno=0&streamtype=1&hashtoken=11abb963e24c98e61b0a31b1c830e143';
	//var url = 'rtsp://202.102.108.138:30298/realplay?devid=112A0000034&channelno=0&streamtype=1&hashtoken=d798df13350f4b8c830cf28aa54c6600';
	//var url = 'rtsp://221.226.150.236:5504/realplay?devid=81151004841&channelno=0&filename=81151004841_ch01_20140718090909_20140718091857&hashtoken=cfcb9bc0b86dbb08bed9371c6e89108c';
	//UDPģʽ
	//document.getElementById("MyActiveX1").InitMediaPlayerWithMediaPath("rtsp://202.102.101.30:62406/realplay?devid=81158957107&channelno=0&streamtype=1&hashtoken=365FF83369C51B9F509EF1634627238B");
	//var url = 'rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp';
	//var url = 'rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov';
	//var url="rtsp://221.226.150.237:47777/realplay?devid=812A930E4BC&channelno=0&streamtype=0&hashtoken=3250592581d706d466fb6b202aeadaf3";
	//var url = 'rtsp://61.160.149.159:18554/14e515cf64693135aa7926f9017299e1c5202c6f.sdp?s=0410fb67d1b66a4ff7cbd2d9461bd7979d56e9c0';
	//TCPģʽ PlayUrl=rtsp://202.102.108.138:58519/realplay?devid=812A930E4BC&channelno=0&streamtype=1&hashtoken=91b2980f3b1dfa98192e184a9612cb29
	
	var url='rtsp://202.102.108.138:58519/realplay?devid=812A930E4BC&channelno=0&streamtype=1&hashtoken=65ce0a2e47fb6d166f126d0e73d98cfb';
	//var url="rtsp://202.102.108.138:58519/realplay?devid=812A930E4BC&channelno=0&streamtype=0&hashtoken=bb10428c1746d89a651c9ed007c473d6";
	//var url="rtsp://221.226.150.237:47777/realplay?devid=812A930E4BC&channelno=0&streamtype=0&hashtoken=c1016247b8feaca324917dbe2b9b1da4";
	document.getElementById("MyActiveX1").InitMediaPlayerWithMediaPath2(url);
	
	//UDPģʽ+����
	//document.getElementById("MyActiveX1").InitMediaPlayerWithMediaPathAndCache(url,2000);

	//TCPģʽ+����
	//document.getElementById("MyActiveX1").InitMediaPlayerWithMediaPathAndCache2(url,2000);
}
//���ӻ������ã���λ���룬Ĭ��1000ms
//ULONG InitMediaPlayerWithMediaPathAndCache(LPCTSTR MediaPath, ULONG CachingTime);
//ULONG InitMediaPlayerWithMediaPathAndCache2(LPCTSTR MediaPath, ULONG CachingTime);




function ReleaseMediaPlayer(){
	document.getElementById("MyActiveX1").ReleaseMediaPlayer();
}




function MediaPlayerPlay(){

	initvlc();
	InitMediaPlayerWithMediaPath();
	document.getElementById("MyActiveX1").MediaPlayerPlay();

	//timer  һ��ȡ10�� �½ӿڻ�ȡ��ǰ״̬() buffer   videoout  end(����stop) error����ReleaseMediaPlayer��Ȼ����ڶ���IPInitMediaPlayerWithMediaPath��    
	setInterval("getState()",10);
	setInterval("showTime()",10);
}

//InitVLCInstance->SaveStreamToFile->Play/Stop
//ULONG SaveStreamToFile(LPCTSTR MediaPath, LPCTSTR Filepath, LPCTSTR Filename);
//������Play֮ǰ����ULONG CTykdSecondaryPluginCtrl::setPlayRate(FLOAT scale)
function StreamToFile(){

	initvlc();
	var url = 'rtsp://221.226.150.236:5504/realplay?devid=81151004841&channelno=0&filename=81151004841_ch01_20140718090909_20140718091857&hashtoken=f734b83d86d76c616f6af92b84cda688';
	var savePath = 'D:/TYKD/';
	document.getElementById("MyActiveX1").SaveStreamToFile(url,savePath,'rtspdownload.avi');
	document.getElementById("MyActiveX1").setPlayRate(16);   //0��32֮��
	document.getElementById("MyActiveX1").MediaPlayerPlay();
	
	//timer  һ��ȡ10�� �½ӿڻ�ȡ��ǰ״̬() buffer   videoout  end(����stop) error����ReleaseMediaPlayer��Ȼ����ڶ���IPInitMediaPlayerWithMediaPath��    
	setInterval("getState()",10);
	setInterval("showTime()",10);
}

function MediaPlayerPause(){
	document.getElementById("MyActiveX1").MediaPlayerPause();
}

function MediaPlayerStop(){
	document.getElementById("MyActiveX1").MediaPlayerStop();
}

function GetMediaPlayerTotalTime(){
	alert(document.getElementById("MyActiveX1").GetMediaPlayerTotalTime());
}

function GetMediaCurrentTime(){
	alert(document.getElementById("MyActiveX1").GetMediaCurrentTime());
}

//������
function setPlayRate(){
	document.getElementById("MyActiveX1").setPlayRate(4);   //0��32֮��
	alert('setPlayRate');
}

//������϶�  ����
function setPlayTime(){
	//MediaPlayerPause();
	document.getElementById("MyActiveX1").setPlayTime(0);
	alert(document.getElementById("MyActiveX1").GetMediaPlayerTotalTime() + ":" +document.getElementById("MyActiveX1").GetMediaCurrentTime());
}

function SetPlayerFullScreen(){
	document.getElementById("MyActiveX1").SetPlayerFullScreen();
}

function SnapShot(){
	document.getElementById("MyActiveX1").TakeSnapShot("c:/a/","����test");
}

function Record(){
	document.getElementById("MyActiveX1").TakeRecord("c://a//","test");
}

function tape(){
	alert('tape');
}

function emitRecord(){
	//alert('emit');
	var flag = alert(document.getElementById("MyActiveX1").StopRecord(1, "hx", "17aae859f81ae86bdc611d10ff0ef9ad", "814B01AF69F", "0"));
	//alert(flag);
}

function cancelRecord(){
	//alert('cancel');
	//alert(document.getElementById("MyActiveX1").StopRecord());
	//alert(document.getElementById("MyActiveX1").GetRecordStatus());
	var flag = document.getElementById("MyActiveX1").StopRecord(0, "", "", "", "");
	alert(flag);
}

function startRecord(){
	var flag = document.getElementById("MyActiveX1").StartRecord();
	//if (flag != 0)
		alert(flag);
	
}

function myTestFunciton(){
	alert(document.getElementById("MyActiveX1").MyTestFuncion())
}

function getRecordStatus(){
	var flag = document.getElementById("MyActiveX1").getRecordStatus();
	alert(flag);
	
}

function getCurrentState(){
	alert(document.getElementById("MyActiveX1").getCurrentState());
}

function isFullScreen(){
	alert(document.getElementById("MyActiveX1").isFullScreen());
}

function setMainDialogSize(){
	document.getElementById("MyActiveX1").SetMaindialogSize(200, 200);
}

function showTime()
    	{
			var playTime = document.getElementById("playTime");
			var currentTime = document.getElementById("MyActiveX1").GetMediaCurrentTime();
    		var totalTime = document.getElementById("MyActiveX1").GetMediaPlayerTotalTime();
			playTime.innerHTML = currentTime+"/"+totalTime;
}

function getState()
		{
  			
		}



</script>


<OBJECT ID="MyActiveX1" WIDTH=600 HEIGHT=400
 CLASSID="CLSID:27FCB6D7-15CD-42E9-88E7-D8DE7CBE8B63">
    <PARAM NAME="_Version" VALUE="65536">
    <PARAM NAME="_ExtentX" VALUE="1323">
    <PARAM NAME="_ExtentY" VALUE="1323">
    <PARAM NAME="_StockProps" VALUE="0">
    <PARAM NAME="enable_slider" VALUE=false>
</OBJECT>
<SCRIPT FOR=MyActiveX1 EVENT=VLCErr()>
	alert(1);
</SCRIPT>
<br></br>
<input type="button" value="initvlc" onclick="initvlc()"/>
<input type="button" value="uninitvlc" onclick="uninitvlc()"/>
<br></br>
<input type="button" value="InitMediaPlayerWithMediaPath" onclick="InitMediaPlayerWithMediaPath()"/>
<input type="button" value="ReleaseMediaPlayer" onclick="ReleaseMediaPlayer()"/>
<br></br>
<input type="button" value="MediaPlayerPlay" onclick="MediaPlayerPlay()"/>
<input type="button" value="StreamToFile" onclick="StreamToFile()"/>
<input type="button" value="MediaPlayerPause" onclick="MediaPlayerPause()"/>
<input type="button" value="MediaPlayerStop" onclick="MediaPlayerStop()"/>
<input type="button" value="setPlayRate" onclick="setPlayRate()"/>
<input type="button" value="setPlayTime" onclick="setPlayTime()"/>
<input type="button" value="SnapShot" onclick="SnapShot()"/>
<input type="button" value="Record" onclick="Record()"/>
<input type="button" value="tape" onclick="tape()"/>
<input type="button" value="emitRecord" onclick="emitRecord()"/>
<input type="button" value="cancelRecord" onclick="cancelRecord()"/>
<input type="button" value="startRecord" onclick="startRecord()"/>
<input type="button" value="mytest" onclick="myTestFunciton()"/>
<input type="button" value="getRecordStatus" onclick="getRecordStatus()"/>
<br></br>
<input type="button" value="GetMediaPlayerTotalTime" onclick="GetMediaPlayerTotalTime()"/>
<input type="button" value="GetMediaCurrentTime" onclick="GetMediaCurrentTime()"/>
<input type="button" value="SetPlayerFullScreen" onclick="SetPlayerFullScreen()"/>

<input type="button" value="getCurrentState" onclick="getCurrentState()"/>

<input type="button" value="isFullScreen" onclick="isFullScreen()"/>
<input type="button" value="setMainDialogSize" onclick="setMainDialogSize()"/>
<br></br>
<div id="playState"></div>
<div id="playTime"><p>0/0</p></div>
</BODY>
</HTML>